package com.ebring.shareEducation.controller;

import com.ebring.shareEducation.bean.Traderecords;
import com.ebring.shareEducation.bean.User;
import com.ebring.shareEducation.bean.response.UserRsp;
import com.ebring.shareEducation.service.TraderecordsService;
import com.ebring.shareEducation.service.UserService;
import com.ebring.shareEducation.utils.JwtUtils;
import com.ebring.shareEducation.utils.RspMsg;
import com.github.pagehelper.PageHelper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.List;
import java.util.Map;

@RestController
@CrossOrigin(origins = "http://wangliang.vipgz1.idcfengye.com", maxAge = 3600)
@Api(value = "法币订单管理" ,tags = {"法币订单管理"})
public class TraderecordsController {

    @Autowired
    private TraderecordsService traderecordsService;


    /**
     * 根据订单ID查找订单
     *
     * @param id 订单ID
     * @return
     */
    @GetMapping("/trade/selectById")
    @ApiOperation(value="根据订单ID查找订单", notes="根据订单ID查找订单")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name = "id", value = "订单ID", required = true, dataType = "String"),
    })
    public RspMsg<Traderecords> selectTradeById(String id) {
        return traderecordsService.selectTradeById(id);
    }

    /**
     * 查找所有订单
     *
     * @param
     * @return
     */
    @GetMapping("/trade/selecttrade")
    @ApiOperation(value="查找所有订单", notes="查找所有订单")
    public RspMsg<Traderecords> selectTradefind() {
        return traderecordsService.selectTradefind();
    }








    /**
     * 法币订单管理模块模糊时查询

     * @param traderecords
     * @param pageNum
     * @param pageSize
     * @return
     */
    @GetMapping("/trade/findTrade")
    @ApiOperation(value="法币订单管理模块模糊时查询", notes="法币订单管理模块模糊时查询")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query",name = "Traderecords", value = "法币订单对象", required = true, dataType = "Traderecords"),
            @ApiImplicitParam(paramType="query",name = "pageNum", value = "页数", required = true, dataType = "Integer"),
            @ApiImplicitParam(paramType="query",name = "pageSize", value = "总页数", required = true, dataType = "Integer"),
    })
    public RspMsg<List<Traderecords>> findTrade(Traderecords traderecords, Integer pageNum, Integer pageSize) {

        if (pageNum == null) {
            pageNum = 1;
        }
        if (pageSize == null) {
            pageSize = 5;
        }
        PageHelper.startPage(pageNum, pageSize);
        return traderecordsService.findTrade(traderecords);
    }


}
